<?php

namespace App\Model;


class GameTaskDayComplete extends Model
{
    protected   $table = 'game_task_day_complete';
    protected   $fillable = ['uid', 'game_id', 'day_task_id','complete_num','is_complete','is_get','create_at', 'update_at'];
    public      $timestamps = false;

    public static function insertRecord($data){
        try{
            self::query()->insert($data);
            return ['code'=>0,'msg'=>'插入成功！'];
        }catch (\Exception $e){
            return ['code'=>1,'msg'=>$e->getMessage()];
        }
    }

    public static function updateRecord($id,$datas){
        try{
            self::query()->where('id',$id)->update($datas);
            return ['code'=>0,'msg'=>'更新成功！'];
        }catch (\Exception $e){
            return ['code'=>1,'msg'=>$e->getMessage()];
        }
    }

    public static function checkRecord($where){
        try{
            $data = self::query()->where($where)->first();
            if(empty($data)){
                return ['code'=>2,'msg'=>'未找到记录！'];
            }
            return ['code'=>0,'msg'=>'获取成功！','data'=>$data->toArray()];
        }catch (\Exception $e){
            return ['code'=>1,'msg'=>$e->getMessage()];
        }
    }
}